package Test;
/**
 * ServletrequestListener用来监听request创建和销毁的事件
 */
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;

public class MyListener implements ServletRequestListener,HttpSessionAttributeListener {
	public MyListener(){
		System.out.println("创建MyListener");
	}
	//监听request销毁事件
	public void requestDestroyed(ServletRequestEvent e) {
		System.out.println("request被销毁");
	}
	//监听request初始换事件
	public void requestInitialized(ServletRequestEvent e) {
		System.out.println("request被初始化");
		System.out.println(e.getServletRequest());

	}


	//监听数据添加事件
	public void attributeAdded(HttpSessionBindingEvent e) {
		System.out.println("向session中添加了数据");

		System.out.println(e.getSession());
	}
	//监听数据移除事件
	public void attributeRemoved(HttpSessionBindingEvent e) {

	}
	//监听数据替换事件
	public void attributeReplaced(HttpSessionBindingEvent arg0) {


	}

}
